package cn.gzmli.dtt.common.service.log;

import cn.gzmli.dtt.common.entity.User;

import javax.servlet.http.HttpSession;

/**
 * @Descript 系统登录日志线程
 * @Author xsx
 * @Date 2018/3/23
 */
public class LoginLogThread implements Runnable {
    private HttpSession session;
    private LoginLogService loginLogService;
    private UserOnlineLogService userOnlineLogService;

    public LoginLogThread(HttpSession session, LoginLogService loginLogService, UserOnlineLogService userOnlineLogService) {
        this.session = session;
        this.loginLogService = loginLogService;
        this.userOnlineLogService = userOnlineLogService;
    }

    @Override
    public void run() {
        try{
            User user = (User) session.getAttribute("User");
            loginLogService.saveLoginLog(session.getId(), user);
            userOnlineLogService.saveOrUpdate(session.getId(), user);
        } catch (Exception e) {
            // TODO
        }
    }
}
